<template>
  <div class="shop">
    <div class="sss">
      <div class="desc">
        <div @click="soso">
          <div class="el-icon-full-screen"></div>
          <el-input v-model="input" placeholder="搜索" class="text"></el-input>
        </div>
      </div>
    </div>
    <el-container>
      <el-container>
        <div>
          <el-aside width="100px">
            <el-row class="tac">
              <el-col>
                <el-menu
                  class="el-menu-vertical-demo"
                  v-for="(item, index) in types"
                  :key="index"
                >
                  <el-menu-item index="1-1" @click="shop(item.t_id)">{{
                    item.name
                  }}</el-menu-item>
                </el-menu>
              </el-col>
            </el-row>
          </el-aside>
        </div>
        <el-container>
          <el-main wdith="400px" class="ppp">
            <el-carousel height="150px">
              <el-carousel-item v-for="(item, index) in image" :key="index">
                <img :src="item.name" alt height="150px" width="300px" />
              </el-carousel-item>
            </el-carousel>
            <el-divider></el-divider>

            <div class="bor" v-for="(item, index) in shops" :key="index">
              <div class="img" @click="imagess(item.id)">
                <img :src="item.img" width="120px" height="170px" />
              </div>
              <div class="contents">
                <div class="title">
                  <span>{{ item.shopname }}</span>
                </div>
                <div class="price">
                  会员价: <span>￥{{ item.price }}</span>
                </div>
                <div class="num">
                  <div class="jishu">
                    <el-input-number
                      :value="num"
                      @change="handleChange"
                      :min="1"
                      :max="100"
                      size="mini"
                    ></el-input-number>
                  </div>
                  <div class="el-icon-shopping-cart-2"></div>
                </div>
              </div>
            </div>
          </el-main>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      num: "",
      types: "",
      shops: "",
      input: "",
      id: "",
      image: "",
      num: 1
    };
  },
  created() {
    this.type();
    this.show();
    this.imgs();
  },
  methods: {
    handleChange(value) {
      console.log(value);
    },
    imgs() {
      let that = this;
      this.$axios
        .get("/img")
        .then(function(response) {
          that.image = response.data;
          console.log(that.image);
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    type() {
      let that = this;
      this.$axios
        .get("/type")
        .then(function(response) {
          that.types = response.data;
          console.log(that.types);
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    show() {
      let that = this;
      this.$axios
        .get("/product")
        .then(function(response) {
          that.shops = response.data.res;
          console.log(that.shops);
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    cost() {
      let that = this;
      this.$axios
        .get("/cost")
        .then(function(response) {
          that.shops = response.data.res;
          console.log(that.shops);
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    shop(t_id) {
      let that = this;
      this.$axios
        .get("/shop", {
          params: {
            id: t_id
          }
        })
        .then(function(response) {
          that.shops = response.data.res;
          console.log(that.shops);
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    search() {
      let that = this;
      this.$axios
        .get("/search", {
          params: {
            name: that.input
          }
        })
        .then(function(response) {
          that.shops = response.data.res;
          console.log(response);
        })
        .catch(function(error) {
          console.log(error);
        });
    },
    imagess(id) {
      this.$router.push({
        path: "/detail",
        query: {
          id: id
        }
      });
    },
    soso() {
      this.$router.push({
        path: "/search"
      });
    }
  }
};
</script>
<style scoped>
.shop {
  width: 500px;
  height: 100%;
  margin: auto;
}
.content {
  width: 400px;
  height: 200px;
  background: skyblue;
}
.ppp {
  display: flex;
  flex-direction: column;
  margin-top: 2px;
}
.bor {
  width: 100%;
  height: 200px;
  display: flex;
  flex-flow: row;
  border: 1px solid black;
}
.img {
  width: 40%;
  height: 100%;
}
.text {
  width: 180px;
  height: 30px;
}
.contents {
  width: 60%;
  height: 100%;
  /* background: orange; */
  display: flex;
  flex-flow: column;
}
.title {
  width: 100%;
  height: 50%;
  font-size: 16px;
  text-align: left;
}
.price {
  width: 100%px;
  height: 20%;
  font-size: 18px;
  /* margin-top: 15px; */

  text-align: left;
}
.price span {
  color: red;
}
.num {
  width: 100%;
  height: 30%;
  display: flex;
  flex-direction: rows;
}
.jishu {
  width: 60%;
  height: 60%;
}
.el-icon-shopping-cart-2 {
  width: 35%;
  height: 60%;
}
/* .butt {
  width: 275px;
  height: 80px;
  margin-top: 5px;
  background: green;
} */

.block {
  width: 100%;
  height: 200px;
}
</style>
>>>>>>> hyb_1
